<template>
  <div style="padding: 40px">
    <div
      class="mb20"
      style="font-weight: 700; font-style: normal; font-size: 16px"
    >
      药品信息
    </div>
    <el-table v-loading="loading" :data="medicalRecordList" :border="true">
      <el-table-column label="用药目的" align="center" prop="purpose"/>
      <el-table-column label="药物名称" align="center" prop="pillsName"/>
      <el-table-column label="用法用量" align="center" prop="amount"/>
      <el-table-column
        label="起始日期"
        align="center"
        prop="beginDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.beginDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { medicalRecordlist } from '@/api/workstation/baseInfo.js'

export default {
  name: 'drugInformation',
  props: ['medicalRecordNo'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 药历用药汇总表格数据
      medicalRecordList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        medicalRecordNo: this.medicalRecordNo,
        medicalType: '4'
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询药历用药汇总列表 */
    getList() {
      this.loading = true
      medicalRecordlist(this.queryParams).then((response) => {
        this.medicalRecordList = response.rows
        this.total = response.total
        this.loading = false
      })
    }
  }
}
</script>

<style></style>
